<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

require_once(dirname(__FILE__) . "/../common/Common.php");
require_once(dirname(__FILE__) . "/../dbcom/UserCom.php");

$common = new Common();
$usercom = new UserCom();

$account = $_REQUEST['username']?$_REQUEST['username']:"";
$password = $_REQUEST['password']?$_REQUEST['password']:"";

if(empty($account)||empty($password)){
    echo json_encode(array("code" => 100, "msg" => "cannot request userinfo"));
    exit();
}

$password1 = $usercom->getPassword($account);

$mypassword = md5($password);
if($password1['password'] == $mypassword){
    $_SESSION['user_id'] = $password1['id'];
    echo json_encode(array("code" => 0, "msg" => "success","data"=>$password1['id']));
}else{
    echo json_encode(array("code" => 100, "msg" => "error password"));
}
exit();
